import 'package:app/shared/constants/common.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

import 'widget/drawer_screen.dart';

class MePage extends StatefulWidget {
  MePage({Key? key}) : super(key: key);

  @override
  _MePageState createState() => _MePageState();
}

class _MePageState extends State<MePage> {
  final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
      drawer: DrawerPerson(),
      body: CustomScrollView(
        slivers: [
          SliverAppBar(
              expandedHeight: 274,
              flexibleSpace: FlexibleSpaceBar(
                background: Container(
                  padding: EdgeInsets.only(top: 90),
                  child: Padding(
                    padding: EdgeInsets.all(sDefaultMarginPadding * 2),
                    child: Column(
                      children: [
                        Row(
                          children: [
                            Container(
                              width: 76,
                              height: 76,
                              child: Stack(
                                children: [
                                  CircleAvatar(
                                    radius: 36,
                                    backgroundImage:
                                        AssetImage("assets/test/girl.jpeg"),
                                  ),
                                  Positioned(
                                      right: 6,
                                      bottom: 4,
                                      child: SvgPicture.asset(
                                        "assets/icons/v_active.svg",
                                        width: 20,
                                      ))
                                ],
                              ),
                            ),
                            SizedBox(
                              width: sDefaultMarginPadding * 2,
                            ),
                            Expanded(
                                child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text(
                                  "如青稞",
                                  style: TextStyle(
                                      fontWeight: FontWeight.bold,
                                      fontSize: 25),
                                ),
                                SizedBox(
                                  height: 5,
                                ),
                                Text(
                                  "逼迫自己成长起来然后骄傲的生活",
                                  style: TextStyle(color: sTextColorDes),
                                ),
                              ],
                            ))
                          ],
                        ),
                        Padding(
                          padding: EdgeInsets.symmetric(
                              horizontal: sDefaultMarginPadding * 4,
                              vertical: sDefaultMarginPadding * 4),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            crossAxisAlignment: CrossAxisAlignment.end,
                            children: [
                              Container(
                                child: Column(
                                  children: [
                                    Text(
                                      "248",
                                      style: TextStyle(
                                          fontWeight: FontWeight.w500,
                                          fontSize: 20),
                                    ),
                                    SizedBox(
                                      height: 8,
                                    ),
                                    Text(
                                      "动态",
                                      style: TextStyle(color: sTextColorDes),
                                    )
                                  ],
                                ),
                              ),
                              SizedBox(
                                width: 1,
                                height: 40,
                                child: DecoratedBox(
                                  decoration: BoxDecoration(
                                      color: Colors.grey.shade300),
                                ),
                              ),
                              Container(
                                child: Column(
                                  children: [
                                    Text(
                                      "248",
                                      style: TextStyle(
                                          fontWeight: FontWeight.w500,
                                          fontSize: 20),
                                    ),
                                    SizedBox(
                                      height: 8,
                                    ),
                                    Text(
                                      "动态",
                                      style: TextStyle(color: sTextColorDes),
                                    )
                                  ],
                                ),
                              ),
                              SizedBox(
                                width: 1,
                                height: 40,
                                child: DecoratedBox(
                                  decoration: BoxDecoration(
                                      color: Colors.grey.shade300),
                                ),
                              ),
                              Container(
                                child: Column(
                                  children: [
                                    Text(
                                      "248",
                                      style: TextStyle(
                                          fontWeight: FontWeight.w500,
                                          fontSize: 20),
                                    ),
                                    SizedBox(
                                      height: 8,
                                    ),
                                    Text(
                                      "动态",
                                      style: TextStyle(color: sTextColorDes),
                                    )
                                  ],
                                ),
                              )
                            ],
                          ),
                        )
                      ],
                    ),
                  ),
                  decoration: BoxDecoration(
                    gradient: LinearGradient(colors: [
                      Colors.white,
                      Color.fromRGBO(212, 241, 255, .9),
                    ], begin: Alignment.bottomCenter, end: Alignment.topCenter),
                  ),
                ),
              ),
              actions: [
                IconButton(onPressed: () {}, icon: Icon(Icons.edit)),
                IconButton(
                    onPressed: () {
                      _scaffoldKey.currentState!.openDrawer();
                    },
                    icon: Icon(Icons.settings)),
              ]),
          SliverToBoxAdapter(
            child: Container(
              padding:
                  EdgeInsets.symmetric(horizontal: sDefaultMarginPadding * 3),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    width: MediaQuery.of(context).size.width / 2 -
                        sDefaultMarginPadding * 4,
                    height: 70,
                    child: ElevatedButton(
                      style: ButtonStyle(
                          foregroundColor:
                              MaterialStateProperty.all(sTextColor),
                          backgroundColor: MaterialStateProperty.all(
                              Color.fromRGBO(102, 255, 237, 1))),
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.end,
                        children: [
                          SvgPicture.asset(
                            "assets/icons/qingzhu.svg",
                            height: 30,
                          ),
                          Text(
                            "我的活动",
                            style: TextStyle(
                                fontSize: 20, fontWeight: FontWeight.bold),
                          )
                        ],
                      ),
                      onPressed: () {},
                    ),
                  ),
                  Container(
                    width: MediaQuery.of(context).size.width / 2 -
                        sDefaultMarginPadding * 4,
                    height: 70,
                    child: ElevatedButton(
                      style: ButtonStyle(
                          foregroundColor:
                              MaterialStateProperty.all(sTextColor),
                          backgroundColor: MaterialStateProperty.all(
                              Color.fromRGBO(255, 243, 100, 1))),
                      child: Row(
                        children: [
                          SvgPicture.asset(
                            "assets/icons/hudong.svg",
                            height: 36,
                          ),
                          Text(
                            "话题互动",
                            style: TextStyle(
                                fontSize: 20, fontWeight: FontWeight.bold),
                          )
                        ],
                      ),
                      onPressed: () {},
                    ),
                  )
                ],
              ),
            ),
          ),
          SliverPadding(
            padding: EdgeInsets.symmetric(
              vertical: sDefaultMarginPadding * 4,
            ),
            sliver: SliverList(
              delegate: SliverChildListDelegate([
                ListTile(
                    leading: Icon(
                      Icons.videocam_outlined,
                      size: 30,
                      color: Colors.black,
                    ),
                    trailing: Icon(Icons.keyboard_arrow_right),
                    title: Text("我的视频")),
                ListTile(
                    leading: Icon(
                      Icons.star_outline_sharp,
                      size: 30,
                      color: Colors.black,
                    ),
                    trailing: Icon(Icons.keyboard_arrow_right),
                    title: Text("我的收藏")),
                ListTile(
                    leading: Icon(
                      Icons.error_outline,
                      size: 30,
                      color: Colors.black,
                    ),
                    trailing: Icon(Icons.keyboard_arrow_right),
                    title: Text("关于我们")),
                ListTile(
                    leading: Icon(
                      Icons.history_outlined,
                      size: 30,
                      color: Colors.black,
                    ),
                    trailing: Icon(Icons.keyboard_arrow_right),
                    title: Text("浏览历史")),
              ]),
            ),
          )
        ],
      ),
    );
  }
}
